/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package proyectoprogra3;

import java.awt.FlowLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.*;
/**
 * 
 * @author Cáceres Cristóbal
 */
public class PJCheckBox extends JPanel implements KeyListener{
    
    private JTextField texto;
    private JCheckBox check;
    private JPanel pn;
   
    public PJCheckBox(){
        this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); 
        
        this.add(pn=new JPanel());
       // pn.setLayout(new BoxLayout(pn, BoxLayout.X_AXIS));
        pn.setLayout(new FlowLayout());
        pn.add(check=new JCheckBox());
        pn.add(texto=new JTextField(30));
        this.repaint();
        //pn.add(bt=new JButton("Agregar"));
        
        //bt.addActionListener(this);
        texto.addKeyListener( this );
    
    }

    @Override
    public void keyTyped(KeyEvent e) {
        
    }

    @Override
    public void keyPressed(KeyEvent e) {
         switch(e.getKeyCode()){
                case KeyEvent.VK_ENTER:
                  this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); 
       this.add(pn=new JPanel());
       this.revalidate();
       
       //pn.setLayout(new BoxLayout(pn, BoxLayout.X_AXIS));
        pn.setLayout(new FlowLayout()); 
        check=new JCheckBox();
        texto=new JTextField(30);
        pn.add(check);
        pn.add(texto); 
        this.repaint();
    }
    }

    @Override
    public void keyReleased(KeyEvent e) {
       
    }
    
    
}
